package main

import (
	"fmt"
	"unicode/utf8"
)

// 判断字符串s是否以prefix开头
func HasPrefix(s, prefix string) bool {
	return len(s) >= len(prefix) && s[:len(prefix)] == prefix
}

// 判断字符串s是否以suffix结尾
func HasSuffix(s, suffix string) bool {
	return len(s) >= len(suffix) && s[len(s)-len(suffix):] == suffix
}

// 判断字符串s是否包含substr
func Contains(s, substr string) bool {
	for i := 0; i < len(s); i++ {
		if HasPrefix(s[i:], substr) {
			return true
		}
	}
	return false
}

func main() {
	var s string = "hello world"
	fmt.Println(HasPrefix(s, "hello"))
	fmt.Println(HasSuffix(s, "worl"))
	fmt.Println(Contains(s, "helloa"))
	var s2 string = "hello, 世界"

	fmt.Println(utf8.RuneCountInString(s2))
	fmt.Println(len(s2))
}
